package net.cmbt.okframework_demo;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import net.cmbt.okframe.okbottomtab.BottomTabTools;
import net.cmbt.okframe.oktablayout.SlidingTabLayout;
import net.cmbt.okframe.oktablayout.listener.OnTabSelectListener;
import net.cmbt.okframe.okupgrade.UpdateApp;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    String[] mTitles = {"国哥", "很穷", "他心里", "很焦灼", "蓝瘦", "香菇"};
    String[] text_bottom = {"国哥", "心情", "不爽", "咋整"};
    int[] seled = {R.mipmap.home_news_icon_check, R.mipmap.disco_icon_current_tab, R.mipmap.study_icon_current_tab, R.mipmap.person_icon_current_tab};
    int[] disseled = {R.mipmap.home_news_icon_uncheck, R.mipmap.disco_icon_dis_tab, R.mipmap.study_icon_dis_tab, R.mipmap.person_icon_dis_tab};
    private ViewPager viewpager;
    private ArrayList<Fragment> mFragments = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
//        setContentView(R.layout.activity_main);
        BottomTabTools bttomTabTools = new BottomTabTools();
        bttomTabTools.editBootomView(R.layout.activity_main, this, seled, disseled, text_bottom, 0);
        bttomTabTools.listenerClick(new BottomTabTools.Listener() {
            @Override
            public void clickTab(View view, int tabIndex, String tabTest) {
                Toast.makeText(MainActivity.this, "" + tabTest, Toast.LENGTH_SHORT).show();
            }
        });

        SlidingTabLayout slidingtablayout = (SlidingTabLayout) findViewById(R.id.slidingtablayout);
        viewpager = (ViewPager) findViewById(R.id.viewpager);


        String url="http://shouji.360tpcdn.com/191206/e01002387a835bbe3aa8c21ade9f3d3a/com.qihoo360.mobilesafe_266.apk";
        new UpdateApp().updateApp(MainActivity.this, "1.0.2", url, "美女提示", "你的APP得更新了", false);


        for (int i = 0; i < 6; i++) {
            mFragments.add(new DemoFragment());
        }
        viewpager.setAdapter(new DemoFmAdapter(getSupportFragmentManager(), mFragments, mTitles));
        slidingtablayout.setViewPager(viewpager, mTitles, this, mFragments, getSupportFragmentManager());
        slidingtablayout.setTextBold(1);
        slidingtablayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
            }

            @Override
            public void onTabReselect(int position) {

            }

            @Override
            public void onClick(int position) {
                viewpager.setCurrentItem(position);
            }
        });


    }


}
